/**
 * 
 */
package kr.co.insoft.core.repository.eventchain.eventchain.impl;

import java.util.List;

import kr.co.insoft.core.mapper.eventchain.eventchain.EventChainMapper;
import kr.co.insoft.core.model.eventchain.eventchain.EventChainEntityModel;
import kr.co.insoft.core.model.paging.EventChainPagingModel;
import kr.co.insoft.core.repository.eventchain.eventchain.EventChainRepository;
import kr.co.insoft.framework.exceptions.ExceptionCode;
import kr.co.insoft.framework.exceptions.RepositoryException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

/**
 * @author skpark
 *
 */
@Repository
public class EventChainRepositoryImpl implements EventChainRepository {

	@Autowired
	EventChainMapper eventChainMapper;
	
	@Override
	public List<EventChainEntityModel> getLists(EventChainPagingModel eventChainPagingModel)
			throws RepositoryException {
		try {
			Assert.notNull(eventChainPagingModel);
			Assert.notNull(eventChainPagingModel.getCurrentPage());
		} catch (IllegalArgumentException e) {
			throw new RepositoryException(ExceptionCode.ARGUMENT_ERROR);
		}

		try {
			return eventChainMapper.getLists(eventChainPagingModel);
		} catch (Exception e) {
			throw new RepositoryException(ExceptionCode.REPOSITORY_EXCEPTION, e);
		}
	}

	/* (non-Javadoc)
	 * @see kr.co.insoft.core.repository.eventchain.eventchain.EventChainRepository#getTotalCount(kr.co.insoft.core.model.paging.PagingModel)
	 */
	@Override
	public int getTotalCount(EventChainPagingModel eventChainPagingModel)
			throws RepositoryException {
		try {
			Assert.notNull(eventChainPagingModel);
		} catch (IllegalArgumentException e) {
			throw new RepositoryException(ExceptionCode.ARGUMENT_ERROR);
		}

		try {
			return eventChainMapper.getTotalCount(eventChainPagingModel);
		} catch (Exception e) {
			throw new RepositoryException(ExceptionCode.REPOSITORY_EXCEPTION, e);
		}
	}

}
